package com.foreknow.mapping;

import com.foreknow.db.DBManager;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by foreknow on 2022/6/27.
 * 工厂类
 * 1. 使用单例模式
 * 2. 创建一个Map容器用来保存xxxMapping对象
 * 3. 提供一个方法用于从容器中获取到xxxMapping对象
 */
public class MappingFactory {

    private static MappingFactory mappingFactory = null;
    private Map<String,EntityMapping> maps = new HashMap<>();
    public static final String ADMIN_MAPPING = "adminMapping";

    private MappingFactory(){
    }

    public static MappingFactory getInstance() {
        if (mappingFactory == null) {
            mappingFactory = new MappingFactory();
            mappingFactory.maps.put(ADMIN_MAPPING,new AdminMapping());
            //mappingFactory.maps.put(XXX_MAPPING,new XXXMapping());
        }
        return mappingFactory;
    }

    public EntityMapping getMap(String key) {
        return maps.get(key);//AdminMapping()
    }
}
